package files;

import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Demo1 {
    public static void main(String[] args) throws IOException {
        File file = new File("C:\\Users\\ASUS\\Desktop\\Files\\test.txt");
        System.out.println("文件大小:"+file.length());
        System.out.println(file.getName());
        System.out.println(file.getAbsoluteFile());
        long modifyTime = file.lastModified();
        Date date = new Date(modifyTime);
        System.out.println(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(date));
        System.out.println(file.exists());
        if(file.exists()){
            file.delete();
        }else{
            file.createNewFile();
        }
//        file.delete();
//        file.createNewFile();
    }
}
